<!-- TOP NAVIGATION MENU FROM DATABASE-->
<?php
	global $xoopsDB, $xoopsModule, $xoopsConfig, $xoopsModuleConfig;
		//GET MOD CONFIG STUFF
		if (!isset($GLOBALS['xoopsModuleConfig']) || $GLOBALS['xoopsModule']->getVar('dirname') != "Top_Menu") {
		  $modhandler = &xoops_gethandler('module');
		  $module = &$modhandler->getByDirname("Top_Menu");
		  $config_handler = &xoops_gethandler('config');
		  $xoopsModuleConfig = &$config_handler->getConfigsByCat(0,$module->getVar('mid')); 
		}
		//END GET MOD CONFIG STUFF
		
		//GET DEFAULT MENU STYLE
		$result = $xoopsDB->query("SELECT * FROM ".$xoopsDB->prefix("topmenu_styles")." WHERE `default` = 1");
		if($result){
			$myrow = $xoopsDB->fetchArray($result);
			$styleDirectory = $myrow['styleDirectory'];
		}
		
		echo"<script type=\"text/javascript\" src=\"".XOOPS_URL."/modules/Top_Menu/include/transmenu_Packed.js\"></script>\n";

		
		//SET STYLE FOR MENU
		echo"<link rel='stylesheet' type='text/css' media='all' href='".XOOPS_URL."/modules/Top_Menu/stylepaks/$styleDirectory/style.css' />\n";


$result = $xoopsDB->query("SELECT * FROM ".$xoopsDB->prefix("tmenu")." WHERE hide=0 ORDER BY weight ASC");

if($result){
	$mod = $GLOBALS['xoopsModule'];
	$dirname = (isset($mod) ? $mod->getVar('dirname') :'system');
	$data = array();
	$x=0;
	while ( $myrow = $xoopsDB->fetchArray($result) ) {
		$data[$x][title] = $myrow['title'];
		$data[$x][target] = $myrow['target'];
		$data[$x][links] = $myrow['link'];
		$data[$x][module] = $myrow['module'];
		++$x;
    }//end while
	 
	 if(count($data) < 1){
	 	return false;
	 }
	 
	 if($xoopsModuleConfig['navDivision'] == 'equal'){
	 	$percent = "width=\"" . round((100/count($data))) . "%\"";
	 }else{
	 	$percent = "";
	 }
}	 
?> 

<div id="wrap" style="text-align:<?PHP echo $xoopsModuleConfig['navAlign'];?>">
<table style='padding:0; margin:0; border:0;width:<?PHP echo $xoopsModuleConfig['navWidth'];?>;' cellpadding="0" cellspacing="0" id="menu" class="menu"> 
<tr id='menuRow'> 

<?PHP
	$XOOPS_URL_STORAGE = XOOPS_URL;
	
for ($i = 0; $i < count($data); $i++) {
		
	//reset url for pledge module
	if($data[$i]['module'] == 'pledge' || $data[$i]['module'] == 'xhld0'){
		$XOOPS_URL = "";
	}else{
		$XOOPS_URL = $XOOPS_URL_STORAGE;
	}

	 if($data[$i]['module'] == $dirname){ 
		if($i == (count($data)-1)){//Currently active cell
			echo "<td $percent class='topNavCellActive'><a href='".$XOOPS_URL.$data[$i]['links']."' id=\"menu".$i."\" TARGET ='".$data[$i]['target']."'>" . $data[$i]['title'] . "</a></td>";
		}else{
			echo "<td $percent class='topNavCellActive'><a href='".$XOOPS_URL.$data[$i]['links']."' id=\"menu".$i."\" TARGET ='".$data[$i]['target']."'>" . $data[$i]['title'] . "</a></td> <td class='divider'>&nbsp;</td>"; 
		}
	}else{ 
		if($i == (count($data)-1)){
			echo "<td class = 'last' $percent><a href='".$XOOPS_URL.$data[$i]['links']."' id=\"menu".$i."\" TARGET='".$data[$i]['target']."'>" . $data[$i]['title'] . "</a></td>"; 
		}else{
			echo "<td $percent><a href='".$XOOPS_URL.$data[$i]['links']."' id=\"menu".$i."\" TARGET='".$data[$i]['target']."'>" . $data[$i]['title'] . "</a></td> <td class='divider'>&nbsp;</td>"; 
		} 
	} 

}	


?>

</tr> 
</table>
</div>

<div id="subwrap"> 
<script type="text/javascript">
<!--
//CREATE SUB MENU ITEMS

if (TransMenu.isSupported()) {
var ms = new TransMenuSet(TransMenu.direction.down, 0,0, TransMenu.reference.bottomLeft);

//NEWS
var menu3 = ms.addMenu(document.getElementById("menu3"));
menu3.addItem("Local News", "<?PHP echo XOOPS_URL; ?>/modules/local_news/index.php?op=default&page=1");
menu3.addItem("Southeast News", "<?PHP echo XOOPS_URL; ?>/modules/local_news/index.php?op=se&page=1");
menu3.addItem("Alaska News", "http://feeds.feedburner.com/aprn-news");
menu3.addItem("National News", "<?PHP echo XOOPS_URL; ?>/modules/xhld0/");





//CREATE MAIN MENU ITEMS
function init() {

		if (TransMenu.isSupported()) {
			TransMenu.initialize();

			//THE MIDDLE MENU ITEMS
			<?PHP for($i=0; $i < count($data); $i++){
				//echo "menu".$i.".onactivate = function() {document.getElementById('menu".$i."').className = 'hover'; };
				//menu".$i.".ondeactivate = function() {document.getElementById('menu".$i."').className = ''; };";
			}?>
			

		}
}





TransMenu.spacerGif = "<?PHP echo XOOPS_URL."/modules/Top_Menu/stylepaks/$styleDirectory/images/x.gif" ?>";
TransMenu.dingbatOn = "<?PHP echo XOOPS_URL."/modules/Top_Menu/stylepaks/$styleDirectory/images/submenu-on.gif" ?>";
TransMenu.dingbatOff = "<?PHP echo XOOPS_URL."/modules/Top_Menu/stylepaks/$styleDirectory/images/submenu-off.gif" ?>"; 
TransMenu.sub_indicator = true; 
TransMenu.menuPadding = 0;
TransMenu.itemPadding = 0;
TransMenu.shadowSize = 2;
TransMenu.shadowOffset = 3;
TransMenu.shadowColor = "#888";
TransMenu.shadowPng = "<?PHP echo XOOPS_URL."/modules/Top_Menu/stylepaks/$styleDirectory/images/grey-40.png" ?>";
TransMenu.backgroundColor = "#bf5f46";
TransMenu.backgroundPng = "<?PHP echo XOOPS_URL."/modules/Top_Menu/stylepaks/$styleDirectory/images/white-90.png" ?>";
TransMenu.hideDelay = 600;
TransMenu.slideTime = 300;
TransMenu.selecthack = 1;
TransMenu.renderAll();

if ( typeof window.addEventListener != "undefined" )
window.addEventListener( "load", init, false );
else if ( typeof window.attachEvent != "undefined" ) {
window.attachEvent( "onload", init);
}else{
if ( window.onload != null ) {
var oldOnload = window.onload;
window.onload = function ( e ) {
oldOnload( e );
init();
}
}else
window.onload = init();
}
}
-->
</script>
</div>